November 13, 2017

Lif Expectency Map

This app represents a way for plotting life expectency at birth on an interactive map using leaflet package just by selecting the year of interest you can also choose your region or the range of interest

2015 Life Expetency Map

leaflet(world_map) %>% addTiles() %>% 
  addPolygons(fillColor = ~pal(lifeExpec),weight = 2,
  opacity = 1,color = "white",fillOpacity = 0.7,label = labels,
  labelOptions = labelOptions(style = list("font-weight" = "normal"),
    textsize = "15px",direction = "auto"))%>%setView( -25,20, 2)

Packages Used

  • sp
    This package for mapping the dataframe to the polygons and creating spatialPolygons data frame
  • maps, maptools
    For creating the polygons for the world countries.
  • countrycode
    To get the iso3 code for countries names to use it for joining with the life expectency dataset
  • leaflet
    for plotting the maps

Data

The Data set is downloaded using the WDI package from World Data Bank then selected the required columns only (year, lifeExpec, country, iso3code, region)